package com.itshare.video.common.config.autoConf;

import com.itshare.video.common.config.properties.QiniuProperties;
import com.itshare.video.common.util.QiniuUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

import javax.annotation.Resource;

/**
 * @Author lyr
 * @create 2020/10/25 8:53
 */

@Configuration
@ConditionalOnProperty("qiniu.oss.bucketName")
@EnableConfigurationProperties(QiniuProperties.class)
public class QiniuAutoConf {

    @Resource
    private QiniuProperties qiniuProperties;

    @Bean
    @Lazy
    public QiniuUtils qiniuUtils() {
        QiniuUtils qiniuUtils = new QiniuUtils();
        qiniuUtils.setQiniuProperties(qiniuProperties);
        return qiniuUtils;
    }

}
